package com.heima.comment.controller.v1;

import com.heima.comment.service.CommentService;
import com.heima.comment.service.WmCommentService;
import com.heima.model.comment.dtos.CommentDTO;
import com.heima.model.comment.dtos.CommentLikeDTO;
import com.heima.model.comment.dtos.CommentSaveDTO;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmCommentAddDTO;
import com.heima.model.wemedia.dtos.WmCommentDTO;
import com.heima.model.wemedia.dtos.WmTopDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Api(value = "评论管理API",tags = "评论管理API")
@RestController
@RequestMapping("/api/v1/comment")
public class CommentController {
  @Autowired
  private CommentService commentService;

  @Autowired
  WmCommentService wmCommentService;

  @ApiOperation("保存评论信息")
  @PostMapping("/save")
  public ResponseResult saveComment(@RequestBody @Validated CommentSaveDTO dto){
    return commentService.saveComment(dto);
  }
  @ApiOperation("保存评论点赞")
  @PostMapping("/like")
  public ResponseResult like(@RequestBody CommentLikeDTO dto){
    return commentService.like(dto);
  }

  @ApiOperation("加载文章评论列表")
  @PostMapping("/load")
  public ResponseResult findByArticleId(@RequestBody CommentDTO dto){
    return commentService.findByArticleId(dto);
  }

  @ApiOperation("自媒体评论列表")
  @PostMapping("/list")
  ResponseResult commentHand(@RequestBody WmCommentDTO dto) {
    return wmCommentService.commentHand(dto);
  }

  @ApiOperation("自媒体评论置顶")
  @PutMapping("/changeTop")
  ResponseResult commentChangeTop(@RequestBody WmTopDTO dto){
    return wmCommentService.commentChangeTop(dto.getId());
  }

  @ApiOperation("自媒体评论回复")
  @PostMapping("/add")
  ResponseResult commentAddHand(@RequestBody WmCommentAddDTO dto){
    return wmCommentService.commentAddHand(dto);
  }

  @ApiOperation("自媒体评论点赞")
  @PostMapping("/likings")
  ResponseResult commentLikings(@RequestBody WmTopDTO dto){
    return wmCommentService.commentLikings(dto);
  }

  @ApiOperation("自媒体评论删除")
  @PostMapping("/delete")
  ResponseResult commentdeleteHand(@RequestBody String id){
    return wmCommentService.commentdeleteHand(id);
  }

}